package org.example.com.Controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.com.bean.Student;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/second")
@Tag(name = "secondController",description = "这个是对second操作的用户访问接口")
public class secondController {
    @GetMapping("/a")
    @Operation(description = "返回了内容")
    public String a() {
        return "23";
    }

    @GetMapping("/b/{c}")
    @Operation(
            description = "该方法根据用户的选择进行计算操作",
            parameters = {
                    @Parameter(name = "a", required = true, description = "计算中的一个数", in = ParameterIn.QUERY),
                    @Parameter(name = "b", required = true, description = "计算中的另外一个数", in = ParameterIn.QUERY),
                    @Parameter(name = "c", required = true, description = "运算类型", in = ParameterIn.PATH),
            }, responses = {
            @ApiResponse(
                    responseCode = "200",
                    description = "返回"
            ),
            @ApiResponse(
                    responseCode = "500",
                    description = "数学异常"
            )

    }
    )
    public Integer b(@RequestParam("a") int a, @RequestParam("b") int b, @PathVariable("c") int c) {
        if (c == 1) {
            return a + b;
        } else if (c == 2) {
            return a - b;
        } else if (c == 3) {
            return a * b;
        } else {
            return a / b;
        }
    }
    @GetMapping("/c")
    @Operation(description = "返回学生信息",responses = {
            @ApiResponse(description = "返回结果")
    })
    public Student c(){
        return new Student();
    }
}